package com.tanhua.dubbo.api.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.api.BlackListApi;
import com.tanhua.dubbo.mapper.BlackListMapper;
import com.tanhua.dubbo.mapper.UserInfoMapper;
import com.tanhua.model.domain.BlackList;
import com.tanhua.model.domain.UserInfo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class BlackListApiImpl implements BlackListApi {

    @Autowired
    private BlackListMapper blackListMapper;

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public Page<UserInfo> queryBlackList(Integer page, Integer pagesize, Long id) {
        Page<UserInfo> pageInfo = new Page<>(page,pagesize);
        userInfoMapper.queryBlackList(pageInfo,id);
        return pageInfo;
    }

    @Override
    public void removeById(Long uid, Long blackUserId) {
        LambdaQueryWrapper<BlackList> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BlackList::getUserId,uid);
        queryWrapper.eq(BlackList::getBlackUserId,blackUserId);
        blackListMapper.delete(queryWrapper);
    }

}